﻿using Furion.DependencyInjection;
using Furion.FriendlyException;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;

namespace ciji.Web.Core
{
    public class LogExceptionHandler : IGlobalExceptionHandler, ISingleton
    {
        private readonly ILogger<LogExceptionHandler> _logger;

        public LogExceptionHandler(ILogger<LogExceptionHandler> logger)
        {
            _logger = logger;
        }

        public Task OnExceptionAsync(ExceptionContext context)
        {
            //记录日志
            _logger.LogError(context.Exception.ToString());
            return Task.CompletedTask;
        }
    }
}